import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { OrderPackageApi } from '#/api/spa/order/package';

import { z } from '#/adapter/form';
import {
    DICT_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';
import {DICT_SPA_TYPE} from "#/utils/dictSpa";

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'orderExtensionId',
      label: '关联spa_order_extension表ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入关联spa_order_extension表ID',
      },
    },
    {
      fieldName: 'packageId',
      label: '关联spa_service_package表ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入关联spa_service_package表ID',
      },
    },
    {
      fieldName: 'packageName',
      label: '套餐名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐名称',
      },
    },
    {
      fieldName: 'packagePrice',
      label: '套餐价格',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐价格',
      },
    },
    {
      fieldName: 'packageDiscount',
      label: '套餐折扣金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐折扣金额',
      },
    },
    {
      fieldName: 'finalPrice',
      label: '最终价格',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入最终价格',
      },
    },
    {
      fieldName: 'packageStatus',
      label: '套餐状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'packageNotes',
      label: '套餐备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入套餐备注',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        placeholder: '请输入权限引用',
      },
    },
    {
      fieldName: 'orderId',
      label: '订单ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单ID',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'orderExtensionId',
      label: '关联spa_order_extension表ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入关联spa_order_extension表ID',
      },
    },
    {
      fieldName: 'packageId',
      label: '关联spa_service_package表ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入关联spa_service_package表ID',
      },
    },
    {
      fieldName: 'packageName',
      label: '套餐名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐名称',
      },
    },
    {
      fieldName: 'packagePrice',
      label: '套餐价格',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐价格',
      },
    },
    {
      fieldName: 'packageDiscount',
      label: '套餐折扣金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐折扣金额',
      },
    },
    {
      fieldName: 'finalPrice',
      label: '最终价格',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入最终价格',
      },
    },
    {
      fieldName: 'packageStatus',
      label: '套餐状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择套餐状态',
      },
    },
    {
      fieldName: 'packageNotes',
      label: '套餐备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入套餐备注',
      },
    },
    {
      fieldName: 'scope',
      label: '权限范围',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限范围',
      },
    },
    {
      fieldName: 'scoperef',
      label: '权限引用',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入权限引用',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'orderId',
      label: '订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入订单ID',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<OrderPackageApi.OrderPackage>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,

    },
    {
      field: 'orderExtensionId',
      title: '关联spa_order_extension表ID',
      minWidth: 120,

    },
    {
      field: 'packageId',
      title: '关联spa_service_package表ID',
      minWidth: 120,

    },
    {
      field: 'packageName',
      title: '套餐名称',
      minWidth: 120,

    },
    {
      field: 'packagePrice',
      title: '套餐价格',
      minWidth: 120,

    },
    {
      field: 'packageDiscount',
      title: '套餐折扣金额',
      minWidth: 120,

    },
    {
      field: 'finalPrice',
      title: '最终价格',
      minWidth: 120,

    },
    {
      field: 'packageStatus',
      title: '套餐状态',
      minWidth: 120,

    },
    {
      field: 'packageNotes',
      title: '套餐备注',
      minWidth: 120,

    },
    {
      field: 'scope',
      title: '权限范围',
      minWidth: 120,

    },
    {
      field: 'scoperef',
      title: '权限引用',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'orderId',
      title: '订单ID',
      minWidth: 120,

    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

